#ifndef _MODULE_MANAGER_HPP
#define _MODULE_MANAGER_HPP

#include <map>

#ifndef _CMP_STR
#define _CMP_STR
struct cmp_str
{
	bool operator()(const char *a, const char *b)
	{
		return std::strcmp(a, b) < 0;
	}
};
#endif

namespace lua
{

class Module;
	
class ModuleManager
{
public:
	static ModuleManager& getInstance()
	{
		static ModuleManager instance;
		return instance;
	}
	Module* getModuleFromName(const char *name);
	friend class Module;
private:
	bool add(Module *module);
	bool remove(Module *module);
	ModuleManager() : mModules(){}
	ModuleManager(const ModuleManager&);
	void operator=(const ModuleManager&);
	~ModuleManager();
private:
	std::map<const char*, Module*, cmp_str> mModules;
};

}

#endif